﻿using Microsoft.CodeAnalysis;
using System.Linq;

namespace CodeAnalysisRuleCollection.Common
{
    internal static class IntroducerHelper
    {
        public static string GetNextName(INamedTypeSymbol containingSymbol, string desiredName)
        {
            var index = 0;
            var name = desiredName;

            var reservedNames = containingSymbol.MemberNames.ToList();

            while (reservedNames.Contains(name))
                name = desiredName + ++index;

            return name;
        }
    }
}
